Intro

This function is written with chromosome maps in mind but generalized for visualizing much more. All that is required is a data frame of segmants with columns called band, start, end.

In the future, I plan to keep it as generalized as possible, maximizing its flexibility and application in various types of analyses. Feel free to suggest ideas, report bugs, or contribute!

Source

source("bands.R")

Human gene locations

chromosomes <- c(paste("chr", 1:21, sep=""), "chrX", "chrY", "chrM")
df <- read.table('data/df.txt', sep="\t", header=TRUE, stringsAsFactors=FALSE)

Default plot

df.1 <- df[sample(1:nrow(df), 2500, replace=F),]
head(df.1)
       band     start       end        name
16058  chr8  86048372  86069697 RNU6ATAC41P
24774 chr12  56237806  56244727    MIR196A2
33304 chr19    813583    813653   LINC00683
34660 chr19  49255471  49256102       NLRP2
21664 chr10 125700435 125719460   EDRF1-AS1
18868  chrX  77885376  77885634        DRP2
draw.bands(df.1, chromosomes, labels=F)

Add colors to highlight regions of interest

df.2 <- df.1
df.2$color <- ifelse(sample(c(T, T, T, F), 2500, replace=T), "grey", "firebrick")
head(df.2)
       band     start       end        name     color
16058  chr8  86048372  86069697 RNU6ATAC41P      grey
24774 chr12  56237806  56244727    MIR196A2      grey
33304 chr19    813583    813653   LINC00683 firebrick
34660 chr19  49255471  49256102       NLRP2 firebrick
21664 chr10 125700435 125719460   EDRF1-AS1      grey
18868  chrX  77885376  77885634        DRP2 firebrick
draw.bands(df.2, chromosomes, labels=F)

Add names for hover info

df.3 <- head(df.2, 500)
head(df.3)
       band     start       end        name     color
16058  chr8  86048372  86069697 RNU6ATAC41P      grey
24774 chr12  56237806  56244727    MIR196A2      grey
33304 chr19    813583    813653   LINC00683 firebrick
34660 chr19  49255471  49256102       NLRP2 firebrick
21664 chr10 125700435 125719460   EDRF1-AS1      grey
18868  chrX  77885376  77885634        DRP2 firebrick
draw.bands(df.3, chromosomes, labels=T)